﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KZ400B
{
    /// <summary>
    /// 参数保留
    /// </summary>
    public partial class AxleManager
    {
        /// <summary>
        /// 参数保留
        /// </summary>
        /// <returns></returns>
        public static bool ParameterPreserve()
        {
            if (!IsOpen)
            {
                return false;
            }

            string data = Protocol.Packet(Protocol.GetParameterPreserve());

            bool rst = sendData(data);
            if (rst)
            {
                try
                {

                    lock (s_spLocker)
                    {
                        if (spLink.CanRead)
                        {
                            string msg = spLink.ReadString(2);
                            if (string.IsNullOrEmpty(msg))
                            {
                                return false;
                            }
                            ProtocolV2.UnpacketResult ur = ProtocolV2.Unpack(msg);
                            rst = ur.Result && ur.Action == AxleActions.ParameterPreserve;
                        }
                    }// link lock
                }
                finally
                {
                    //setIsLocked(false);
                }
            }
            return rst;
        }//contact
    }
}
